<?php
    class Zendvn_Acl_Acl extends Zend_Acl
    {
        public function __construct(){
            // Khai bao cac nhom quyen(role)
            $this->addRole(new Zend_Acl_Role('guest'));
            $this->addRole(new Zend_Acl_Role('member'), 'guest');
            $this->addRole(new Zend_Acl_Role('editor'), 'member');
            $this->addRole(new Zend_Acl_Role('admin'), 'editor');
            
            // Khai bao cac resources cho module Admin
            $this->addResource(new Zend_Acl_Resource('admin-dthink:index'));
            $this->addResource(new Zend_Acl_Resource('admin-dthink:user'));
            $this->addResource(new Zend_Acl_Resource('admin-dthink:congratulations'));
            $this->addResource(new Zend_Acl_Resource('admin-dthink:gallery'));
            
            // Khai bao cac resources cho module Default
            $this->addResource(new Zend_Acl_Resource('default:index'));
            
            // Khai bao cac resources cho module Error
            $this->addResource(new Zend_Acl_Resource('error:error'));
            
            // Cap quyen truy cap cho cac nhom
            // Guest
            $this->allow('guest', 'default:index', null);
            $this->allow('guest', 'admin-dthink:index', array('index', 'login', 'logout'));
            $this->allow('guest', 'error:error', null);
            
            // Member
            $this->allow('member', 'default:index', null);
            $this->deny('member', 'default:index', array('forgotpassword'));
            
            // Editor
            $this->allow('editor', 'admin-dthink:user', array('profile', 'changepassword'));
            
            // Admin
            $this->allow('admin', 'admin-dthink:index', null);
            $this->allow('admin', 'admin-dthink:user', null);
            $this->allow('admin', 'admin-dthink:congratulations', null);
            $this->allow('admin', 'admin-dthink:gallery', null);
        }
    }
